home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / groff108.lha / groff-1.08 / acgroff.m4 next >
M4 Source File  |  1993-04-19  |  9KB  |  381 lines

  1. dnl Autoconf macros for groff.
  2. dnl Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
  3. dnl 
  4. dnl This file is part of groff.
  5. dnl 
  6. dnl groff is free software; you can redistribute it and/or modify it under
  7. dnl the terms of the GNU General Public License as published by the Free
  8. dnl Software Foundation; either version 2, or (at your option) any later
  9. dnl version.
  10. dnl 
  11. dnl groff is distributed in the hope that it will be useful, but WITHOUT ANY
  12. dnl WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. dnl FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14. dnl for more details.
  15. dnl 
  16. dnl You should have received a copy of the GNU General Public License along
  17. dnl with groff; see the file COPYING.  If not, write to the Free Software
  18. dnl Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19. dnl
  20. define(GROFF_EXIT,[rm -f conftest* core; exit 1])dnl
  21. define(GROFF_PREFIX,[AC_PROVIDE([$0])AC_PREFIX(grops)AC_PREFIX(gcc)])dnl
  22. define(GROFF_PROG_CCC,
  23. [AC_PROVIDE([$0])AC_REQUIRE([AC_PROG_CC])dnl
  24. cc_compile='$CCC conftest.cc -o conftest $CCLIBS $LIBS >/dev/null 2>&1'
  25. AC_SUBST(CCLIBS)
  26. if test -z "$CCC"; then
  27. # See whether the C compiler is also a C++ compiler.
  28. echo checking if C compiler is also a C++ compiler
  29. cat <<EOF > conftest.cc
  30. #ifdef __cplusplus
  31.   yes
  32. #endif
  33. EOF
  34. $CC -E conftest.cc >conftest.out 2>&1
  35. if egrep yes conftest.out >/dev/null 2>&1; then
  36.   CCC="$CC"
  37. fi
  38. fi
  39. AC_PROGRAM_CHECK(CCC,g++,g++,)
  40. AC_PROGRAM_CHECK(CCC,CC,CC,)
  41. AC_PROGRAM_CHECK(CCC,cc++,cc++,)
  42. if test -z "$CCC"; then
  43. cat <<EOM
  44. This package requires a C++ compiler, but I couldn't find one.
  45. Set the environment variable CCC to the name of your C++ compiler.
  46. EOM
  47. GROFF_EXIT
  48. fi
  49. echo checking that C++ compiler can compile very simple C++ program
  50. GROFF_CC_TEST_PROGRAM([
  51. extern "C" { void exit(int); }
  52. int main() { exit(0); }
  53. ],,
  54. cat <<EOM
  55. $CCC was unable successfully to compile a very simple C++ program
  56. (the C++ program was in a file with a suffix of .cc)
  57. EOM
  58. GROFF_EXIT
  59. ,)
  60. echo checking that C++ static constructors and destructors are called
  61. GROFF_CC_TEST_PROGRAM([
  62. extern "C" {
  63.   void exit(int);
  64.   void _exit(int);
  65. }
  66. int i;
  67. struct A {
  68.   char dummy;
  69.   A() { i = 1; }
  70.   ~A() { if (i == 1) _exit(0); }
  71. };
  72. A a;
  73. main() { exit(1); }
  74. ],,
  75. cat <<EOM
  76. $CCC is not installed correctly: static constructors and destructors do not work
  77. EOM
  78. GROFF_EXIT
  79. ,)
  80. GROFF_CC_COMPILE_CHECK([C++ header files],[#include <stdio.h>],
  81. [fopen(0, 0);],,
  82. [cat <<\EOF
  83. Your header files do not appear to support C++.
  84. I was unable to compile and link a simple C++ program that used a function
  85. declared in <stdio.h>.
  86. If you're using gcc/g++, you should install libg++.
  87. EOF
  88. GROFF_EXIT])])dnl
  89. define(GROFF_CC_COMPILE_CHECK,
  90. [AC_PROVIDE([$0])AC_REQUIRE([GROFF_PROG_CCC])echo checking for $1
  91. cat <<EOF >conftest.cc
  92. [$2]
  93. extern "C" { void exit(int); }
  94. int main() { exit(0); } void t() { [$3] }
  95. EOF
  96. dnl Don't try to run the program, which would prevent cross-configuring.
  97. if eval $cc_compile; then
  98.   ifelse([$4], , :, [$4])
  99. ifelse([$5], , , [else
  100.   $5
  101. ])dnl
  102. fi
  103. rm -f conftest*])dnl
  104. dnl
  105. define(GROFF_CC_TEST_PROGRAM,
  106. [AC_PROVIDE([$0])AC_REQUIRE([GROFF_PROG_CCC])ifelse([$4], , ,
  107. [AC_REQUIRE([AC_CROSS_CHECK])if $cross_compiling
  108. then
  109.   $4
  110. else
  111. ])dnl
  112. cat <<EOF > conftest.cc
  113. [$1]
  114. EOF
  115. rm -f conftest
  116. eval $cc_compile
  117. if test -s conftest && (./conftest) 2>/dev/null; then
  118.   ifelse([$2], , :, [$2])
  119. ifelse([$3], , , [else
  120.   $3
  121. ])dnl
  122. fi
  123. ifelse([$4], , , fi
  124. )dnl
  125. rm -f conftest*])dnl
  126. dnl
  127. define(GROFF_PAGE,
  128. [AC_REQUIRE([GROFF_PREFIX])
  129. if test -z "$PAGE" && test -r $prefix/lib/groff/font/devps/DESC
  130. then
  131.     if grep "^paperlength 841890" \
  132.         $prefix/lib/groff/font/devps/DESC >/dev/null 2>&1
  133.     then
  134.         PAGE=A4
  135.     else
  136.         PAGE=letter
  137.     fi
  138. fi
  139. if test -z "$PAGE"
  140. then
  141.     dom=`awk '([$]1 == "dom" || [$]1 == "search") { print [$]2; exit}' \
  142.         /etc/resolv.conf 2>/dev/null`
  143.  
  144.     if test -z "$dom"
  145.     then
  146.         dom=`(domainname) 2>/dev/null | tr -d '+'`
  147.         if test -z "$dom"
  148.         then
  149.             dom=`(hostname) 2>/dev/null | grep '\.'`
  150.         fi
  151.     fi
  152.  
  153. changequote(,)dnl
  154.     # If the top-level domain is two letters and it's not `us' or `ca'
  155.     # then they probably use A4 paper.
  156.     case "$dom" in
  157.     *.[Uu][Ss]|*.[Cc][Aa]) ;;
  158.     *.[A-Za-z][A-Za-z]) PAGE=A4 ;;
  159.     esac
  160. changequote([,])dnl
  161. fi
  162. test -n "$PAGE" || PAGE=letter
  163. echo guessing $PAGE size paper
  164. AC_SUBST(PAGE)])dnl
  165. dnl
  166. define(GROFF_PERL_PATH,
  167. [echo checking for perl
  168. PERLPATH=
  169. saveifs="$IFS"; IFS="${IFS}:"
  170. for dir in $PATH; do
  171.   test -z "$dir" && dir=.
  172.   if test -f $dir/perl; then
  173.      PERLPATH="$dir/perl"
  174.      break
  175.   fi
  176. done
  177. IFS="$saveifs"
  178. AC_SUBST(PERLPATH)])dnl
  179. dnl
  180. define(GROFF_WCOREFLAG,
  181. [echo checking for w_coredump
  182. AC_TEST_PROGRAM([
  183. #include <sys/types.h>
  184. #include <sys/wait.h>
  185. main()
  186. {
  187. #ifdef WCOREFLAG
  188.   exit(1);
  189. #else
  190.   int i = 0;
  191.   ((union wait *)&i)->w_coredump = 1;
  192.   exit(i != 0200);
  193. #endif
  194. }
  195. ],AC_DEFINE(WCOREFLAG,0200),,)])dnl
  196. dnl
  197. define(GROFF_MMAP,
  198. [AC_COMPILE_CHECK([mmap],[#include <sys/types.h>
  199. #include <sys/mman.h>],
  200. [char *p = mmap(0, 0, PROT_READ, MAP_PRIVATE, 0, 0); munmap(p, 0);],
  201. AC_DEFINE(HAVE_MMAP))])dnl
  202. dnl;
  203. define(GROFF_SYS_SIGLIST,
  204. [AC_COMPILE_CHECK([sys_siglist],,changequote(,)dnl
  205. extern char *sys_siglist[]; sys_siglist[0] = 0;,changequote([,])dnl
  206. AC_DEFINE(HAVE_SYS_SIGLIST))])dnl
  207. dnl
  208. define(GROFF_STRUCT_EXCEPTION,
  209. [AC_COMPILE_CHECK([struct exception],[#include <math.h>],
  210. [struct exception e;],
  211. AC_DEFINE(HAVE_STRUCT_EXCEPTION))])dnl
  212. define(GROFF_COOKIE_BUG,
  213. [echo checking for gcc/g++ delete bug
  214. GROFF_CC_TEST_PROGRAM([
  215. #include <stdlib.h>
  216. #include <stddef.h>
  217.  
  218. int testit = 0;
  219.  
  220. int main()
  221. {
  222.   testit = 1;
  223.   int *p = new int;
  224.   delete p;
  225.   testit = 0;
  226.   exit(1);
  227. }
  228.  
  229. static unsigned dummy[3];
  230.  
  231. void *operator new(size_t n)
  232. {
  233.   if (testit) {
  234.     dummy[1] = -(unsigned)(dummy + 2);
  235.     return dummy + 2;
  236.   }
  237.   else
  238.     return (void *)malloc(n);
  239. }
  240.  
  241. void operator delete(void *p)
  242. {
  243.   if (testit) {
  244.     if (p == dummy)
  245.       exit(0);
  246.   }
  247.   else
  248.     free(p);
  249. }
  250. ],AC_DEFINE(COOKIE_BUG),,)])dnl
  251. dnl
  252. define(GROFF_CFRONT_ANSI_BUG,
  253. [AC_REQUIRE([GROFF_LIMITS_H])echo checking for cfront ANSI C INT_MIN bug
  254. GROFF_CC_TEST_PROGRAM([#include <stdlib.h>
  255. #ifdef HAVE_CC_LIMITS_H
  256. #include <limits.h>
  257. #else
  258. #define INT_MAX 2147483647
  259. #endif
  260.  
  261. #undef INT_MIN
  262. #define INT_MIN (-INT_MAX-1)
  263.  
  264. int main()
  265. {
  266.   int z = 0;
  267.   exit(INT_MIN < z);
  268. }
  269. ],AC_DEFINE(CFRONT_ANSI_BUG),,)])dnl
  270. dnl
  271. define(GROFF_ARRAY_DELETE,
  272. [GROFF_CC_COMPILE_CHECK(new array delete syntax,,
  273. changequote(,)dnl
  274. char *p = new char[5]; delete [] p;changequote([,]),
  275. ,AC_DEFINE(ARRAY_DELETE_NEEDS_SIZE))])dnl
  276. dnl
  277. define(GROFF_BROKEN_SPOOLER_FLAGS,
  278. [test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7
  279. echo using default value of ${BROKEN_SPOOLER_FLAGS} for grops -b option
  280. AC_SUBST(BROKEN_SPOOLER_FLAGS)])dnl
  281. dnl
  282. define(GROFF_PRINT,
  283. [if test -z "$PSPRINT"
  284. then
  285.     AC_PROGRAMS_CHECK(LPR,lpr)
  286.     AC_PROGRAMS_CHECK(LP,lp)
  287.     if test -n "$LPR" && test -n "$LP"
  288.     then
  289.         # HP-UX provides an lpr command that emulates lpr using lp,
  290.         # but it doesn't have lpq; in this case we want to use lp
  291.         # rather than lpr.
  292.         AC_PROGRAMS_CHECK(LPQ,lpq)
  293.         test -n "$LPQ" || LPR=
  294.     fi
  295.     if test -n "$LPR"
  296.     then
  297.         PSPRINT="$LPR"
  298.     elif test -n "$LP"
  299.     then
  300.         PSPRINT="$LP"
  301.     fi
  302. fi
  303. AC_SUBST(PSPRINT)
  304. # Figure out DVIPRINT from PSPRINT.
  305. if test -n "$PSPRINT" && test -z "$DVIPRINT"
  306. then
  307.     if test "X$PSPRINT" = "Xlpr"
  308.     then
  309.         DVIPRINT="lpr -d"
  310.     else
  311.         DVIPRINT="$PSPRINT"
  312.     fi
  313. fi
  314. AC_SUBST(DVIPRINT)])dnl
  315. define(GROFF_GETOPT,
  316. [GROFF_CC_COMPILE_CHECK([declaration of getopt in stdlib.h],
  317. [#include <stdlib.h>],
  318. [int opt = getopt(0, 0, 0); optarg = "foo"; optind = 1;],
  319. AC_DEFINE(STDLIB_H_DECLARES_GETOPT))
  320. GROFF_CC_COMPILE_CHECK([declaration of getopt in unistd.h],
  321. [#include <sys/types.h>
  322. #include <unistd.h>],
  323. [int opt = getopt(0, 0, 0);],
  324. AC_DEFINE(UNISTD_H_DECLARES_GETOPT))
  325. ])dnl
  326. define(GROFF_PUTENV,
  327. [GROFF_CC_COMPILE_CHECK([declaration of putenv],[#include <stdlib.h>],
  328. [putenv((char *)0);],
  329. AC_DEFINE(STDLIB_H_DECLARES_PUTENV))])dnl
  330. define(GROFF_ETAGSCCFLAG,
  331. [echo checking for etags C++ option
  332. for flag in p C
  333. do
  334.     test -z "$ETAGSCCFLAG" || break
  335.     >conftest.c
  336.     (etags -$flag -o /dev/null conftest.c >/dev/null 2>&1) 2>/dev/null &&
  337.         ETAGSCCFLAG="-$flag"
  338.     rm -f conftest.c
  339. done
  340. AC_SUBST(ETAGSCCFLAG)])dnl
  341. define(GROFF_LIMITS_H,
  342. [AC_PROVIDE([$0])GROFF_CC_COMPILE_CHECK(['C++ <limits.h>'],
  343. [#include <limits.h>],
  344. [int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;],
  345. AC_DEFINE(HAVE_CC_LIMITS_H))])dnl
  346. define(GROFF_TRADITIONAL_CPP,
  347. [GROFF_CC_COMPILE_CHECK([traditional preprocessor],
  348. [#define name2(a,b) a/**/b],[int name2(foo,bar);],
  349. AC_DEFINE(TRADITIONAL_CPP))])dnl
  350. define(GROFF_TIME_T,
  351. [GROFF_CC_COMPILE_CHECK([time_t],[#include <time.h>],
  352. [time_t t = time(0); struct tm *p = localtime(&t);],,
  353. AC_DEFINE(LONG_FOR_TIME_T))])dnl
  354. define(GROFF_UNISTD_H,
  355. [GROFF_CC_COMPILE_CHECK(['C++ <unistd.h>'],[#include <unistd.h>],
  356. dnl Bison generated parsers have problems with C++ compilers other than g++.
  357. dnl So byacc is preferred over bison.
  358. [read(0, 0, 0);],AC_DEFINE(HAVE_CC_UNISTD_H))])dnl
  359. define(GROFF_PROG_YACC,
  360. [AC_PROGRAM_CHECK(YACC, byacc, byacc, )
  361. AC_PROGRAM_CHECK(YACC, bison, bison -y, yacc)
  362. ])dnl
  363. dnl GROFF_CSH_HACK(if hack present, if not present)
  364. define(GROFF_CSH_HACK,
  365. [echo 'checking for csh # hack'
  366. cat <<EOF >conftest.sh
  367. #!/bin/sh
  368. true || exit 0
  369. export PATH || exit 0
  370. exit 1
  371. EOF
  372. chmod +x conftest.sh
  373. if echo ./conftest.sh | (csh >/dev/null 2>&1) >/dev/null 2>&1
  374. then
  375.     :; $1
  376. else
  377.     :; $2
  378. fi
  379. rm -f conftest.sh
  380. ])dnl
  381.